package com.ebt.m.policy;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.ebt.m.R;
import com.ebt.m.customer.fragment.BaseLazyFragment;
import com.ebt.m.policy.view.BrandsProductListView;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by Damon.Han on 2018/4/10 0010.
 *
 * @author Damon
 */
public class FrgChooseByBrand extends BaseLazyFragment {

    @BindView(R.id.content_brand)
    FrameLayout contentBrand;
    @BindView(R.id.list_view)
    BrandsProductListView listView;
    Unbinder unbinder;

    public static FrgChooseByBrand newInstance() {
        FrgChooseByBrand frg = new FrgChooseByBrand();
        Bundle bundle = new Bundle();
        frg.setArguments(bundle);
        return frg;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View contentView = inflater.inflate(R.layout.fragment_choose_by_brand, container, false);
        unbinder = ButterKnife.bind(this, contentView);
        getDataFromServer(null);
        return contentView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    public void getDataFromServer(Map<String, String> map) {
        Map<String, String> params = new HashMap<>();
        if (map!=null) {
            for (String key : map.keySet()) {
                params.put(key, map.get(key));
            }
        }
        listView.update(params);
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
